﻿using System;
using System.Data.SqlClient;
using System.Data.Objects;
using WindowsPhoneAudioStreaming.MockRadioStation.Data;
using System.Collections.Generic;
using System.Linq;

namespace WindowsPhoneAudioStreaming.MockRadioStation.Logic
{
    public class MockRadioStationLogic
    {
        private MockRadioStationDataContainer dataContext;

        public MockRadioStationLogic()
        {
            this.dataContext = new MockRadioStationDataContainer();

        }

        public List<Program> GetPrograms()
        {
            return this.dataContext.Programs.ToList();
        }
        
        public void SetupMockData()
        {
            this.AddProgram(new Program()
            {
                Name = "Cafe Latte",
                AssociatedImageUrl = "http://network.absoluteradio.co.uk/core/player/artists/playlist/5235.jpg",
                AssociatedPodcastUrl = "http://www.abc.net.au/triplej/tomandalex/rss/podcast.xml",
                Description = "The latest in smooth soul and black-influenced pop - Alan Ross presents the history, influences and latest of smooth soul and black-influenced pop. Features the Black Roots segment in the second hour.",
                StartTime = new TimeSpan(12, 0, 0),
                Presenters = "Alan Ross",
               EndTime = new TimeSpan(14, 0, 0)
            });

            this.AddProgram(new Program()
            {
                Name = "Three Chords and the Truth",
                AssociatedImageUrl = "http://network.absoluteradio.co.uk/core/player/artists/playlist/5479.jpg",
                AssociatedPodcastUrl = "http://www.abc.net.au/triplej/listen/free_mp3s.xml",
                Description = "Blues, Folk and Gospel.",
                StartTime = new TimeSpan(14, 0, 0),
                Presenters = "Andy, Max and Alex",
                EndTime = new TimeSpan(16, 0, 0)
            });

            this.AddProgram(new Program()
            {
                Name = "Top 40",
                AssociatedImageUrl = "http://network.absoluteradio.co.uk/core/player/artists/playlist/187.jpg",
                AssociatedPodcastUrl = "http://www.abc.net.au/triplej/podcast/unearthed.xml",
                Description = "Dictumst nibh nisi sed aliquam integer eleifend sem ornare sit nisl purus quisque vivamus nunc risus aliquam odio orci aliquet vel blandit.",
                StartTime = new TimeSpan(16, 0, 0),
                Presenters = "Marty K",
                EndTime = new TimeSpan(18, 0, 0)
            });

            this.AddProgram(new Program()
            {
                Name = "Funk train",
                AssociatedImageUrl = "http://network.absoluteradio.co.uk/core/player/artists/playlist/11413.jpg",
                AssociatedPodcastUrl = "http://www.abc.net.au/triplej/podcast/unearthed.xml",
                Description = "Aliquam class aenean maecenas integer praesent curae cras donec duis etiam fusce mauris quisque nunc vivamus amet aliquam nam ante accumsan bibendum nullam aptent aliquet blandit auctor arcu sed diam dis est commodo hac leo lorem mus eget.",
                StartTime = new TimeSpan(18, 0, 0),
                Presenters = "Andrew Hallam",
                EndTime = new TimeSpan(20, 0, 0)
            });
        }

        public void AddProgram(Program program)
        {
            this.dataContext.Programs.AddObject(program);
            this.dataContext.SaveChanges();
        }

        public void Close()
        {
            this.dataContext.Dispose();
        }
    }
}
